<section class="scrollable wrapper">
	<div class="row">
		<div class="col-md-12">
			<section class="panel">
				<header class="panel-heading">
					<a href="<?php echo site_url('smn-admin/ptk_pujasera/add'); ?>"  class="btn btn-success btn-sm"><i class="fa fa-plus"></i> Tambah Pujasera</a>
					<i class="fa fa-info-sign text-muted" data-toggle="tooltip" data-placement="bottom" data-title="ajax to load the data."></i> 
				</header>
				<div class="table-responsive">
					<table class="table table-striped m-b-none" data-ride="datatables">
						<thead>
							<tr>
								<th width="20%">Nama</th>
								<th width="40%">Tanggal Lahir</th>
								<th width="20%">Tempat Lahir</th>
								<th width="20%">NIP</th>
								<th width="20%">Jabatan</th>
								<th width="10%">Aksi</th>
							</tr>
					</thead>
						<tbody>
						</tbody>
					</table>
				</div>
			</section>
		</div>
	</div>
</section>

<script>

$(document).ready(function() {
	$('[data-ride="datatables"]').each(function() {
		var oTable = $(this).dataTable( {
			"bProcessing": true,
			"bServerSide": true,
			"sServerMethod": "POST",
			"sAjaxSource": "<?php echo site_url('smn-admin/ptk_pujasera/json_pujasera'); ?>",
			"sPaginationType": "full_numbers",
			"sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
			"aoColumns": [
				{ "mData": 'nama'},
				{ "mData": 'tanggal_lahir'},
				{ "mData": 'tempat_lahir'},
				{ "mData": 'nip'},
				{ "mData": 'id_jabatan'},
				{ "mData": 'aksi'}
			],
			"aaSorting": [[1, 'desc']],
			"fnServerData": fnDataTablesPipeline,
			"bStateSave": true,
			"bDeferRender": true,
			"fnDrawCallback": function() {
				$('table').find('[data-toggle="ajaxModal"]').on('click',
				  function(e) {
					e.preventDefault();
					if($(this).attr('data-cache') == 'true') {
						$.ajaxSetup ({cache: true});
					} else {
						$.ajaxSetup ({cache: false});
					}
					$('#ajaxModal').remove();
					var $this = $(this)
					  , $remote = $this.data('remote') || $this.attr('href')
					  , $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>');
					$('body').append($modal);
					$modal.modal();
					$modal.load($remote);
				  }
				);

				$('.btn-delete-cabang').click(function(e) {
					var c = confirm('Anda akan menghapus Cabang ini, Lanjutkan?');
					if(!c) e.preventDefault();
					
				});
			}
		} );
	});
	
	
});
</script>
